<template>
  <div class="cont-wrapper no-sidebar">
    <div class="block-container container">
      <div class="title">审核编排</div>
      <div class="table-wrapper">
        <el-table :data="tableData" border class="c-table" style="width: 100%" v-loading="loading">
          <el-table-column prop="areaName" label="所在区域"></el-table-column>
          <el-table-column prop="describe" label="状态"></el-table-column>
          <el-table-column prop="res" label="编排结果">
            <template slot-scope="scope">
              <a href="javascript:;" class="priview" @click="$router.push({name: 'examLayout', query: {id: scope.row.areaId}})">查看编排结果</a>
            </template>
          </el-table-column>
          <el-table-column label="确认审核">
            <template slot-scope="scope">
              <el-button size="mini" type="primary" @click="handleExamine(scope.row.id)">确认审核</el-button>
            </template>
          </el-table-column>
        </el-table>
        <!-- <kw-pagination v-if="tableData.length" :listQuery="listQuery" @changeCurrentPage="changeCurrentPage"></kw-pagination> -->
      </div>
    </div>
      <el-dialog
    title="操作提示"
    :visible.sync="dialogVisible"
    center
    width="30%">
    <p style="line-height:66px;text-align:center;font-size:16px;">请确认审核结果</p>
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="checkResult(1)">通过</el-button>
      <el-button @click="checkResult(2)">不通过</el-button>
    </span>
  </el-dialog>
  </div>
</template>

<script>
import { mapState } from 'vuex'
export default {
  name: 'examine',
  data () {
    return {
      tableData: [
      ],
      loading: false,
      listQuery: {
        page: 1,
        pageSize: 10,
        total: null,
        totalPages: null
      },
      dialogVisible: false,
      checkId: 0
    }
  },
  computed: mapState({
     changeNotify: state => state.changeNotify
  }),
  methods: {
    // 确认审核
    handleExamine (id) {
      this.dialogVisible = true
      this.checkId = id
    },
    checkResult (state) {
      this.$http.modifyOrganize({
        id: this.checkId,
        statuCode: state
      }).then(res => {
        if (res.code === 20000) {
          this.$message.success('操作成功！')
          this.getExamineList()
          this.$store.commit('CHANGE_NOTIFY', !this.changeNotify)
        } else {
          this.$message.error(res.msg)
        }
        this.dialogVisible = false
      })
    },
    // 获取审核编排列表
    getExamineList () {
      let that = this
      that.loading = true
      this.tableData = []
      that.$http.getSubmitAllOrganize().then(res => {
        if (res.size > 0) {
          this.tableData = res.data
        } else {
          // that.$message.error('暂无需审核的编排信息')
        }
        that.loading = false
      })
    },
    // 翻页
    changeCurrentPage (queryData) {
      this.listQuery.page = queryData.page
      this.listQuery.pageSize = queryData.pageSize
      this.getExamineList()
    }
  },
  mounted () {
    this.getExamineList()
  }
}
</script>

<style lang="scss" scoped>
.priview{
  color: #4177ff;
}
</style>
